package com.siblings.loan.ui.user.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.lib.base.utils.ImageUtil
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/7/18 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class SibFeedbackImageAdapter(recyclerView: RecyclerView?): SIBRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_feedback_image) {

    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.ivDelete) //删除
        helper.setItemChildClickListener(R.id.ivImage)//选择
    }

    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        val ivImage = helper.getImageView(R.id.ivImage)
        val ivDelete = helper.getImageView(R.id.ivDelete)

        //是否是默认图片
        val isDefault = model.optBoolean("isDefault",true)
        if (isDefault){
            ivImage.setImageResource(R.mipmap.pic_user_feedback_upload)
            ivDelete.visibility = View.INVISIBLE
        } else {
            ImageUtil.instance!!.loadImageUrl(mContext,ivImage,model.optString("imgPath"))
            ivDelete.visibility = View.VISIBLE
        }
    }
}